function opponentInPossession = OpponentInPossession(P,S, mode)

opponentInPossession = false; % functions outputs false by default

for i=1:numel(S),

    if(numel(S{i}{1}) == 3 && S{i}{2} ~= P{2}) % if the element from the state is a player but not a teammate 
        P = S{i};
        
        if(PlayerInPossession(P,S,mode)) % check if the player has possession of the ball
            opponentInPossession = true;
            break;
        end

    end   
end    

end